﻿using System;
using System.Collections.Generic;
using System.Text;
using Av;
using System.Threading;

namespace Av
{
    class Program
    {
        static void Main(string[] args)
        {

            Log4cs.Dir = Common.GetPath() + "Logs\\";
            Log4cs.FileName = "cron_{0}.log";
            Log4cs.OutputToConsole = true;

            string[] arCron = { 
                "1-10 * 3 1-12/3 1-3,6 Test"
                , "0-59/5 0-23/8 * * * Every8hours5minutes"
                , "50 23 * 1-12/2 * Every2monthes"
                , "* * * * 3 EveryWednesday"
                , "0-59/5 16 * * * EverydayAt16*"
            };

            Log4cs.Log("Starting Cron test...");
            Cron c = new Cron();
            c.ParseCronline(arCron);
            Log4cs.Log(c.ToString());

            bool isOk = true;
            while(isOk)
            {
                string[] arTask = c.FindTask();
                if (arTask != null)
                {
                    Log4cs.Log("Tasks to be executed at {0}", DateTime.Now.ToString("HH:mm:ss"));
                    foreach (string task in arTask)
                    {
                        Log4cs.Log("\t{0}", task);
                    }
                }
                Thread.Sleep(1000);
            }
        }
    }
}
